package Student_information.Controller;

import Student_information.Javabean.Student;
import Student_information.Service.StudentService;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class StudentManage {
    public void Oper() {

        //创建对象
        StudentService ss = new StudentService();

        //创建集合，用于存放学生信息
        List<Student> list = new ArrayList<>();

        //模拟数据
        list.add(new Student("gx01", "张三", "男", "18"));
        list.add(new Student("gx02", "李四", "女", "19"));
        list.add(new Student("gx03", "王五", "男", "20"));
        Scanner sc = new Scanner(System.in);

        // 展示主操作界面
        System.out.println("欢迎进入XX系统");
        System.out.println("1 查询学生信息");
        System.out.println("2 增加学生信息");
        System.out.println("3 删除学生信息");
        System.out.println("4 修改学生信息");
        System.out.println("5 退出系统");
        while (true) {

            // 用户输入数字进行循环操作(增删改查)
            System.out.println("请输入1 查 2 增 3 删 4 改 5 退出选择操作");
            int i = sc.nextInt();
            // 分支执行
            switch (i) {
                case 1:
                    //调用方法
                    ss.findAll(list);
                    break;
                case 2:
                    ss.addStu(list);
                    break;
                case 3:
                    ss.deleteStu(list);
                    break;
                case 4:
                    ss.updateStu(list);
                    break;
                case 5:
                    System.out.println("欢迎下次再来");
                    System.exit(0);// 正常退出JVM
                    break;
            }
        }
    }
}
